//
//  QZDataUpdate.h
//  Tika
//
//  Created by tikeios_001 on 2024/4/29.
//

#import <Foundation/Foundation.h>
#import "QZVideoModel.h"
#import "QZCommentModel.h"

NS_ASSUME_NONNULL_BEGIN

typedef enum : NSUInteger {
    QZDataUpdateLike, //点赞
    QZDataUpdateCollect, //收藏
    QZDataUpdateHua, //送花
    QZDataUpdateFollow, //关注
    QZDataUpdateComment, //评论
    QZDataUpdateNoLike, //不感兴趣
    QZDataUpdateBlock, //拉黑
    QZDataUpdateCancelBlock, //取消拉黑
    QZDataUpdatePayVideo, //付费视频更新
    QZDataUpdateIsTop, //置顶
    QZDataUpdateNoSeeTa, //不看他
    QZDataUpdateCancelNoSeeTa, //不看他
    QZDataUpdateTaSeeMe, //不让他看
    QZDataUpdateCancelTaSeeMe,
    QZDataUPdateSM, //私密视频
    QZDataUPdateUpdate, //发布成功
    QZDataUPdateDelVideo, //删除视频
} QZDataUpdateType;

@protocol QZDataUpdateDelegate <NSObject>
@optional
- (NSMutableArray *_Nullable)sourceData; //返回监听的视频原始数据
- (void)updateData:(QZVideoModel *_Nonnull)data index:(NSInteger)index type:(QZDataUpdateType)type;//用于视频播放数据更新 如点赞，收藏等
- (void)delData:(QZVideoModel *_Nonnull)data index:(NSInteger)index type:(QZDataUpdateType)type;//用于视频播放数据删除更新
- (void)updateOtherFollow:(id _Nullable )followId isFollow:(id _Nullable )isFollow; //用于其它情况的关注更新， 比如在个人主页点击了关注，则全局更新视频对因的关注
- (void)delObjWithId:(id _Nullable )delId type:(QZDataUpdateType)type; //用于拉黑等删除更新，拉黑用户时删除该用户对应的本地视频数据
//- (void)replyCommentData:(TFGroupCommentData *_Nonnull)sectionData rowData:(TFChildCommentData *_Nonnull)rowData videoData:(QZVideoModel *_Nonnull)data replyVideo:(BOOL)is; //全局回复评论的回调

- (void)sourceDataUpdate; //探索用到
- (void)scrollToIndex:(NSInteger)index; //探索用到 滚动到对应的位置
//- (void)delComment:(TFGroupCommentData *_Nullable)sData childData:(TFChildCommentData *_Nullable)rData; //删除评论更新

- (void)likeVideo:(QZVideoModel *)data type:(QZDataUpdateType)type; //用于更新我的喜欢视频
- (void)collectionVideo:(QZVideoModel *)data type:(QZDataUpdateType)type; //用于更新我的喜欢视频

- (void)smVideo:(QZVideoModel *)data type:(QZDataUpdateType)type;//用于更新我的私密

- (void)publicVideo:(QZVideoModel *)data type:(QZDataUpdateType)type;//用于更新发布
@end

@interface QZDataUpdate : NSObject
@property (strong, nonatomic) NSPointerArray *videoDatas;
@property (strong, nonatomic) NSMutableArray *followIds; //用于保存关注了的用户 刷新关注页
@property (strong, nonatomic) NSMutableArray *unFollowIds;
+ (instancetype)share;
/*添加控制器，用于监听数据变化
 1.添加数据
 2.实现对应的代理
 3.代理中处理更新数据
 注意：target 当type == QZDataUpdateComment的时候，target将会回调调用代理的所有方法（target只针对：- (void)replyCommentData:(TFGroupCommentData *_Nonnull)mainData rowData:(TFChildCommentData *_Nonnull)rowData videoData:(QZVideoModel *_Nonnull)data
 */
//- (void)addController:(id<QZDataUpdateDelegate>)controller YVDeprecated("已废弃此方法，请使用 ”addListenerObj:“ 替代");
- (void)addListenerObj:(id<QZDataUpdateDelegate>)obj;
//- (void)removeController:(UIViewController<QZDataUpdateDelegate> *)controller;
/*更新点赞数据*/
- (void)updateLike:(QZVideoModel *)video excludeTarget:(id)target;
/*更新收藏数据*/
- (void)updateCollection:(QZVideoModel *)video excludeTarget:(id)target;
/*更新收藏数据*/
- (void)updateHua:(QZVideoModel *)video excludeTarget:(id)target;
/*更新不感兴趣数据*/
- (void)updateNoLike:(id)videoId excludeTarget:(id)target;
/*更新关注数据*/
- (void)updateFollow:(id)mid isFollow:(id)isFollow excludeTarget:(id)target;
/*更新拉黑用户*/
- (void)blockUser:(id)mid excludeTarget:(id)target; //用于用户拉黑
- (void)cancelBlockUser:(id)mid excludeTarget:(id)target;
/*更新评论数据*/
- (void)updateComment:(QZVideoModel *)video excludeTarget:(id)target;
//- (void)updateComment:(QZVideoModel *)video sectionData:(TFGroupCommentData *_Nonnull)mainData rowData:(TFChildCommentData *_Nonnull)rowData excludeTarget:(id)target updateExcludeTarget:(id)ex_target replyVideo:(BOOL)is; //评论数据透传  多级评论数据同步
- (void)addCommentWithVideoId:(id)vid excludeTarget:(id)target; //直接添加一条评论数据，快捷回复时需要找到本地对应的视频数据 对视频评论 +1
/*更新付费视频数据*/
- (void)updatePayVideo:(QZVideoModel *)video excludeTarget:(id)target;
/*通知数据刷新*/
- (void)updateSourceData;
- (void)updateScrollToIndex:(NSInteger)index;
/*更新置顶视频数据*/
- (void)updateIsTop:(QZVideoModel *)video excludeTarget:(id)target;
/*更新删除的评论*/
//- (void)updateDelComment:(TFGroupCommentData *)gData childData:(nullable TFChildCommentData *)cData excludeTarget:(id  _Nullable)target;
/*更新不看Ta*/
- (void)updateNoSeeTa:(id)mid excludeTarget:(id)target;
- (void)cancelNoSeeTa:(id)mid excludeTarget:(id)target;
/*更新不让Ta看*/
- (void)updateTaSeeMe:(id)mid excludeTarget:(id)target;
/**更新私密数据**/
- (void)updateSMVideo:(QZVideoModel *)data excludeTarget:(id)target;
/**更新发布状态**/
- (void)updatePublicVideo:(QZVideoModel *)data excludeTarget:(id)target;
/**删除作品更新**/
- (void)delVideo:(QZVideoModel *)data excludeTarget:(id)target;
@end

NS_ASSUME_NONNULL_END
